/**
 * 分类导航数据
 */

import { findHeadCategory } from '@/api/home'

export default {
  namespaced: true, // 开启命名空间
  state: {
    navs: []
  },

  mutations: {
    // 存储navs(同步)
    setNavs (state, payload) {
      state.navs = payload
    }
  },
  actions: {
    // 调用后台获取navs的接口
    async getNavs ({ commit }, payload) {
      const { result } = await findHeadCategory()
      console.log(result)
      commit('setNavs', result)
    }
  }
}
